package com.kuang.demo02;

public class UserServiceProxy implements UserService{
    private UserServiceImpl userService;

    public UserServiceImpl getUserService() {
        return this.userService;
    }

    public void setUserService(UserServiceImpl userService) {
        this.userService = userService;
    }

    //    public UserServiceProxy(){
//    }
    @Override
    public void add() {
        this.log("add");   //这样打印日志，不用改变代码，只需要改变传入log()方法的参数！！
        this.userService.add();
    }

    @Override
    public void delete() {
        this.log("deleta");
        this.userService.delete();
    }

    @Override
    public void update() {
        this.log("update");
        this.userService.update();
    }

    @Override
    public void query() {
        this.log("query");
        this.userService.query();
    }
    public void log(String message){ //打印日志
        System.out.println("使用了"+message+"方法");
    }
}
